package hoowin.basic.dao.springImp;

import hoowin.basic.dao.IFollowDao;

import org.springframework.jdbc.core.support.JdbcDaoSupport;

public class FollowDao extends JdbcDaoSupport implements IFollowDao {

	@Override
	public boolean addFollow(int followeeId, int followerId, int type) {
		String sql = "insert into basic_user_follows (followee_id, follower_id, type) values (?, ?, ?)";
		if(super.getJdbcTemplate().update(sql,followeeId, followerId, type)>0)return true;
		else return false;
	}

	@Override
	public boolean deleteFollow(int followeeId, int followerId) {
		if(super.getJdbcTemplate().update("delete from basic_user_follows where followee_id="+followeeId+" and follower_id="+followerId)>0)return true;
		return false;
	}

	@Override
	public boolean updateFollow(int followeeId, int followerId, int type) {
		String sql="update basic_user_follows set type=? where followee_id=? and follower_id=?";
		if(super.getJdbcTemplate().update(sql, type, followeeId, followerId)>0){
			return true;
		}else return false;
	}

}
